package com.lrkj.web.phone;


import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.core.page.TableDataInfo;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.waitress.domain.CruiserTask;
import com.lrkj.waitress.domain.PathDetail;
import com.lrkj.waitress.domain.Place;
import com.lrkj.waitress.service.ICruiserTaskService;
import com.lrkj.waitress.service.IPathDetailService;
import com.lrkj.waitress.service.IPlaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/phone/Cruiser")
@Api(tags = "房屋认证审批")
public class CruiserController extends BaseController {

    @Autowired
    private ICruiserTaskService cruiserTaskService;

    @Autowired
    private IPlaceService placeService;

    @Autowired
    private IPathDetailService pathDetailService;



    /**
     * 查询巡逻任务列表
     */
    @ApiOperation(value = "查询巡逻任务列表", notes = "查询巡逻任务列表")
    @GetMapping("/TaskList")
    public TableDataInfo TaskList(CruiserTask cruiserTask)
    {
        startPage();
        this.changeParameter(cruiserTask.getParams());
        List<CruiserTask> list = cruiserTaskService.selectCruiserTaskList(cruiserTask);
        return getDataTable(list);
    }



    /**
     * 完成巡检任务
     * @param cruiserTask
     * @return
     */
    @PutMapping("/updCruiserOff")
    public AjaxResult updCruiserOff(@RequestBody CruiserTask cruiserTask){
        return  toAjax(cruiserTaskService.updCruiserOff(cruiserTask));
    }



    /**
     * 查询地点管理列表
     */
    @ApiOperation(value = "查询地点管理列表", notes = "查询地点管理列表")
    @GetMapping("/placeList")
    public TableDataInfo placeList(Place place)
    {
        startPage();
        this.changeParameter(place.getParams());
        List<Place> list = placeService.selectPlaceList(place);
        return getDataTable(list);
    }


    /**
     * 新增地点管理
     */
    @ApiOperation(value = "新增地点管理", notes = "新增地点管理")
    @Log(title = "地点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Place place)
    {
        return toAjax(placeService.insertPlace(place));
    }



    /**
     * 查询路线明细列表
     */
    @ApiOperation(value = "查询路线明细列表", notes = "查询路线明细列表")
    @GetMapping("/pathDeatilList")
    public TableDataInfo pathDeatilList(PathDetail pathDetail)
    {
        startPage();
        this.changeParameter(pathDetail.getParams());
        List<PathDetail> list = pathDetailService.selectPathDetailList(pathDetail);
        return getDataTable(list);
    }


}
